﻿namespace CN2P.Web.Controllers.Api.Proxy
{
    using System.Net;
    using System.Net.Http;
    using System.Web.Http;
    using CN2P.ServiceModel;

    public class ReviewsApiProxyController : BaseApiProxyController
    {

        [AcceptVerbs("GET")]
        public ProductReviewModelPagedList Get(string prodId, int pageSize = 10, int pageIndex = 0)
        {
            return client.ProductsService.GetReviews(prodId, pageIndex, pageSize);
        }

        [AcceptVerbs("GET")]
        public ProductReviewModelResponse GetReview(string prodId, string reviewId)
        {
            return client.ProductsService.GetReview(prodId, reviewId);
        }

        [AcceptVerbs("DELETE")]
        public void RemoveReview(string prodId, string reviewId)
        {
            client.ProductsService.RemoveReview(prodId, reviewId);
        }

        [AcceptVerbs("PUT")]
        public HttpResponseMessage UpdateReview(string prodId, string reviewId, ProductReviewModel model)
        {
            client.ProductsService.UpdateReview(prodId, reviewId, model);

            return Request.CreateResponse(HttpStatusCode.Created);
        }

        [AcceptVerbs("POST")]
        public HttpResponseMessage Post(string prodId, ProductReviewModel review)
        {
            client.ProductsService.AddReview(prodId, review);
            return Request.CreateResponse(HttpStatusCode.Created);
        }
    }
}